#include "head.h"

int getparameter(const char *key, char value[])
{
    FILE* stream = fopen("config.ini", "r");

    int length = strlen(key);
    while(1)
    {
        char buf[30] = {0};
        char* res = fgets(buf, sizeof(buf), stream);
        if(res == NULL)
        {
            printf("%s: 没有配置文件", key);
            return -1;
        }
             
        if(memcmp(key, buf, length) == 0)
        {
            strcpy(value, buf + length + 1);
            return 0;
        }
    }
}